﻿using System;
using System.Data;
using HRM.Common;

namespace HRM.BusinessLogic
{
    public class ChotSoInfo : Standard_Info
    {

        public ChotSoInfo()
        {
           
        }


        private int _ChotSo_ID;

        public int ChotSo_ID
        {
            get { return _ChotSo_ID; }
            set { _ChotSo_ID = value; }
        }
        private int _ChotSo_BranchID;

        public int ChotSo_BranchID
        {
            get { return _ChotSo_BranchID; }
            set { _ChotSo_BranchID = value; }
        }
        private int _ChotSo_EmployeeID;

        public int ChotSo_EmployeeID
        {
            get { return _ChotSo_EmployeeID; }
            set { _ChotSo_EmployeeID = value; }
        }
        private DateTime _ChotSo_NgayNhap;

        public DateTime ChotSo_NgayNhap
        {
            get { return _ChotSo_NgayNhap; }
            set { _ChotSo_NgayNhap = value; }
        }
        private string _ChotSo_Loai;

        public string ChotSo_Loai
        {
            get { return _ChotSo_Loai; }
            set { _ChotSo_Loai = value; }
        }

        private string _ChotSo_HoVaTen;

        public string ChotSo_HoVaTen
        {
            get { return _ChotSo_HoVaTen; }
            set { _ChotSo_HoVaTen = value; }
        }

        private string _ChotSo_SoSo;
        public string ChotSo_SoSo
        {
            get { return _ChotSo_SoSo; }
            set { _ChotSo_SoSo = value; }
        }
    }

    public class ChotSo_Controller : Standard_Controller
    {
        #region "Contructor"
        private static ChotSo_Controller _instance;
        protected ChotSo_Controller() { }
        protected new void Dispose()
        {
            _instance = null;
        }
        private static object _syncLock = new object();
        public static ChotSo_Controller Instance()
        {
            if (_instance == null)
            {
                lock (_syncLock)
                {
                    if (_instance == null)
                        _instance = new ChotSo_Controller();
                }
            }
            return _instance;
        }
        public static ChotSo_Controller Instance(String transName)
        {
            if (!String.IsNullOrEmpty(transName))
            {
                ChotSo_Controller _instanceTrans = new ChotSo_Controller();
                _instanceTrans.Trans_Name = transName;
                return _instanceTrans;
            }
            else
                return Instance();
        }
        #endregion

        public const String cs_Table_Name = "";

        public ChotSoInfo ChotSo_GetInfo(int ChotSo_Id)
        {
            return CBO.FillObject<ChotSoInfo>(DataConnect.ExecuteRow(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_ChotSo_GetInfo"), ChotSo_Id));
        }

        public DataTable ChotSo_GetAll(int Branch_Id, string Loai)
        {
            return DataConnect.ExecuteTable(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_ChotSo_GetAll"), Branch_Id, Loai);
        }

        public int ChotSo_Insert(ChotSoInfo eInfo)
        {
            return Globals.Object_GetValue<int>(DataConnect.ExecuteScalar(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_ChotSo_Insert"), 
                eInfo.ChotSo_SoSo,
                eInfo.ChotSo_EmployeeID,
                eInfo.ChotSo_HoVaTen,
                eInfo.ChotSo_Loai,
                eInfo.ChotSo_BranchID
            ));
        }

        public bool ChotSo_Update(ChotSoInfo eInfo)
        {
            return Globals.Object_GetValue<bool>(DataConnect.ExecuteScalar(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_ChotSo_Update"), 
                eInfo.ChotSo_ID,
                eInfo.ChotSo_Loai
                ));
        }

        public bool ChotSo_Delete(int ChotSo_Id)
        {
            return DataConnect.ExecuteNonQuery(DataConnect.WorkingConnect, Procedure_Name(cs_Table_Name, "HRM_ChotSo_Delete"), ChotSo_Id) > 0;
        }
    }
}
